package models;
import java.util.*;
//import javax.persistence.*;  
//import play.db.jpa.Model;  
import play.libs.*;
import play.libs.F.*;


public class Notify {
    private static Map<Long,Notify> instances = new HashMap<Long,Notify>();  

    public  ArchivedEventStream<Map<String,String>> chatEvents  = new ArchivedEventStream<Map<String,String>>(200);

    public  ArchivedEventStream<MBlog> postEvents = new ArchivedEventStream<MBlog>(200);

    public  ArchivedEventStream<User> followerEvents = new ArchivedEventStream<User>(200); 

    public  ArchivedEventStream<MBlog> memtionEvents = new ArchivedEventStream<MBlog>(200);

    public  ArchivedEventStream<MBlog> commentEvents = new ArchivedEventStream<MBlog>(200);

    private Notify(){}

    public static Notify getNotifyById(long id){
            if(instances.get(id)==null){
                instances.put(id,new Notify());
            }
            return instances.get(id);
    }
    public void deleteChatEvents(){
            chatEvents = new ArchivedEventStream<Map<String, String>>(200);
    }

    public void publishChatEvent(Map<String,String> chmemtionEvent ){
            chatEvents.publish(chmemtionEvent);
    }
    
    public Promise<List<IndexedEvent<Map<String,String>>>> getChatEvents(long lastReveived){
            return chatEvents.nextEvents(lastReveived);
    }

    public void deleteMBlogEvents(){
            postEvents = new ArchivedEventStream<MBlog>(200);
    } 

    public void publishMBlogEvent(MBlog post){
            postEvents.publish(post);
    }

    public Promise<List<IndexedEvent<MBlog>>> getMBlogEvents(long lastReveived){
           return postEvents.nextEvents(lastReveived);
    }
    
    public void deleteFansEvents(){
            followerEvents = new ArchivedEventStream<User>(200);
    }
    public void publishFansEvent(User fans){
            followerEvents.publish(fans);
    }
    public Promise<List<IndexedEvent<User>>> getFansEvents(){
            return followerEvents.nextEvents(0);
    }

    public void deleteAtEvents(){
           memtionEvents = new ArchivedEventStream<MBlog>(200);
    }

    public void publishAtEvent(MBlog post){
         memtionEvents.publish(post);
    }

    public Promise<List<IndexedEvent<MBlog>>> getAtEvents(){
        return memtionEvents.nextEvents(0);
    }

    public void deleteCommentEvents(){
           commentEvents = new ArchivedEventStream<MBlog>(200);
    }

    public void publishCommentEvent(MBlog post){
         commentEvents.publish(post);
    }

    public Promise<List<IndexedEvent<MBlog>>> getCommemtEvents(){
        return commentEvents.nextEvents(0);
    }
 
}
